<?php
/*
 * Author :pandiam &basanas
 */
session_start();
require_once ('../BL/BL.php');
require_once ('include/functions.php');

if (!isset($_SESSION['uid']) || $_SESSION['uid'] == -1) {
    UI_registerError('msg_warning', "You are not logged in.");
    header('Location: login.php');
    exit(0);
}

if (isset($_GET['id']))
{
    if (!ctype_digit((string )$_GET['id']))
    {
        UI_registerError('msg_error', "Invalid category request");
        header("location: index.php");
        exit(0);
    }
    $catid = $_GET['id'];
}
else
{
    UI_registerError('msg_warning', "You haven't selected a category to delete!");
    header("location: profile.php");
    exit(0);
}

if (($res = BL_delete_category($_GET['id'], $_SESSION['uid'])) < 0)
{
    BL_registerError($res);
    BL_flusherrors();
}
else
{
    UI_registerError("msg_success", "Successfully deleted category.");
}

header("location: profile.php");
exit(0);

?>